package com.youi.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youi.common.Common;
import com.youi.common.DelStatus;
import com.youi.dao.StoreDao;
import com.youi.entity.Groupleader;
import com.youi.entity.Leaderstore;
import com.youi.entity.Store;
import com.youi.service.GroupleaderService;
import com.youi.service.LeaderstoreService;
import com.youi.service.StoreService;

@Service
public class StoreServiceImpl extends BaseServiceImpl<Store> implements StoreService{
		
		private StoreDao storeDao;
		
		@Autowired
		private LeaderstoreService leeaLeaderstoreService;
		@Autowired
		private GroupleaderService groupleaderService;
		@Autowired
		private LeaderstoreService leaderstoreService;
		@Autowired
		public void setfaultRecordDao(StoreDao storeDao){
			this.storeDao=storeDao;
			super.setBaseDAO(storeDao);
		}

		@Override
		public List<Store> getNearbyStoreList(Map<String, Object> params,
				Map<String, Object> searchParams, Map<String, Object> sortParams, Integer pageIndex, Integer pageNum,
				Map<String, Object> gtParams, Map<String, Object> ltParams, Double latitude, Double longitude) {
			// TODO Auto-generated method stub
			return storeDao.getNearbyStoreList(params, searchParams, sortParams, pageIndex, pageNum, gtParams, ltParams, latitude, longitude);
		}

		@Override
		public void getAuthStoreStatus(List<Store> storeList) {
			// TODO Auto-generated method stub
			if (storeList!=null&&storeList.size()>0) {
				for (Store store : storeList) {
					Map<String, Object> prams=new HashMap<String, Object>();
					prams.put(Common.DELSTATUS, DelStatus.NODEL);
					prams.put("storeId", store.getId());
					prams.put("level", 1);
					Leaderstore leaderstore=leaderstoreService.getByParam(prams);
					if (leaderstore!=null) {
						store.setVerify(1);
					}else {
						store.setVerify(0);
					}
			}
		}
	}		
}